package org.xt.module.view;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.sql.Sql;
import org.nutz.dao.sql.SqlCallback;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.lang.util.NutMap;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.By;
import org.nutz.mvc.annotation.Filters;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.filter.CheckSession;
import org.xt.constants.Const;
import org.xt.entity.DataDetailsAutoTemp;

@IocBean
public class DataDetailsAutoViewModule {
	@Inject
	private Dao dao;
	
	@At({"/N6_1F/Chuwei/Details/auto/list"})
	@Ok("jsp:jsp.dataDetailsAuto.list")
	public void list(){
	}
	
	@At("/N6_1F/Chuwei/Details/auto/in")
	@Ok("jsp:jsp.dataDetailsAuto.in")
	public void in(){
		
	}
	
	@At("/N6_1F/Chuwei/Details/auto/xjxcin")
	@Ok("jsp:jsp.dataDetailsAuto.xjxcin")
	public NutMap xjxcin(){
		Sql sql = Sqls.create("select top 1 box from tb_data_1fgjeh_details_auto order by box desc");
		sql.setCallback(new SqlCallback() {
			@Override
			public List<Integer> invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
				// TODO Auto-generated method stub
				List<Integer> list = new ArrayList<>();
				while(rs.next()){
					list.add(rs.getInt("box"));
				}
				return list;
			}
		});
		dao.execute(sql);
		org.xt.module.api.DataDetailsAutoApiModule.box =  sql.getList(Integer.class).get(0) + 1;
		org.xt.module.api.DataDetailsAutoApiModule.num = 0;
		dao.delete(dao.query(DataDetailsAutoTemp.class, null));
		return NutMap.NEW().addv("num", org.xt.module.api.DataDetailsAutoApiModule.num)
				.addv("box", String.format("%05d", org.xt.module.api.DataDetailsAutoApiModule.box));
	}
	
	@At("/N6_1F/Chuwei/Details/auto/out")
	@Ok("jsp:jsp.dataDetailsAuto.out")
	public void out(){
		
	}
	
	@At("/N6_1F/Chuwei/Details/auto/biangeng")
	@Ok("jsp:jsp.dataDetailsAuto.biangeng")
	public void biangeng(){
		
	}
	
	@At("/N6_1F/Chuwei/Details/auto/outByChuwei")
	@Ok("jsp:jsp.dataDetailsAuto.outByChuwei")
	public void outByChuwei(){
		
	}
}
